import CallInterface from '@/api'
import requestName from '@/api/common/request-name'
import { setLocal, getLocal } from '@/lib/logicHandle'
import $global from '@/module/tipsGroup'
import dayjs from 'dayjs'
const userInfo = getLocal('user-info')
const userIdObj = {
  userId: userInfo.userId
  // user_id: 'LITE1689502421397'
  // user_id: '1'
}
export default {
  async login ({ state, commit }, receive = {}) {
    const res = await CallInterface(requestName.SET_LOGIN, receive, { interType: 'special', method: 'GET' })
    setLocal('user-info', res)
    $global.$toast('success', '登录成功')
    return res
  },
  async fjOrHj ({ state, commit }, receive = {}) {
    const sendData = {
      fjr_user_id: userInfo.userId,
      ...receive
    }
    const res = await CallInterface(requestName.SET_FJORHJ, sendData)
    return res
  },
  // 我的信件
  async myxjList ({ state, commit }, receive = {}) {
    const sendData = {
      ...userIdObj,
      ...receive
    }
    const res = await CallInterface(requestName.SET_MYXJ, sendData, { method: 'GET' })
    return res
  },
  // 信件详情
  async getxjbyld ({ state, commit }, receive = {}) {
    const sendData = {
      ...receive
    }
    const res = await CallInterface(requestName.GETXJBYLD, sendData, { method: 'GET' })
    return res
  },
  // 随机获取信件
  // async sjhqxj ({ state, commit }, receive = {}) {
  //   const sendData = {
  //     ...userIdObj
  //   }
  //   const res = await CallInterface(requestName.SET_SJHQXJ, sendData)
  //   return res
  // },
  // 获取个人信息
  async getjbxxbyuserid ({ state, commit }, receive = {}) {
    const sendData = {
      ...userIdObj
    }
    const res = await CallInterface(requestName.GET_GETJBXXBYUSERID, sendData, { interType: 'special', method: 'GET' })
    return res
  },
  // 获取用户职业信息
  // async getZylist ({ state, commit }, receive = {}) {
  //   const sendData = {
  //     ...userIdObj
  //   }
  //   const res = await CallInterface(requestName.GET_ZYLIST, sendData, { interType: 'special', method: 'GET' })
  //   return res.records
  // },
  // 编辑用户职业
  async getBjyhzy ({ state, commit }, receive = {}) {
    const sendData = {
      ...userIdObj,
      ...receive
    }
    const res = await CallInterface(requestName.GET_BJYHZY, sendData)
    return res
  },
  // 新增用户职业
  async getAdduserzy ({ state, commit }, receive = {}) {
    const sendData = {
      ...userIdObj,
      ...receive
    }
    const res = await CallInterface(requestName.GET_ADDUSERZY, sendData)
    return res
  },
  // 删除用户职业
  async setDeluserzy ({ state, commit }, receive = {}) {
    const sendData = {
      ...receive
    }
    const res = await CallInterface(requestName.SET_DELUSERZY, sendData)
    return res
  },
  // 修改用户的基本信息
  async setUpd ({ state, commit }, receive = {}) {
    const sendData = {
      ...userIdObj,
      ...receive
    }
    const res = await CallInterface(requestName.GET_UPD, sendData, { method: 'PUT' })
    return res
  },
  // 获取随机的灯笼
  async getRandomlist ({ state, commit }, receive = {}) {
    const res = await CallInterface(requestName.GET_RANDOMLIST, {}, { interType: 'special', method: 'GET' })
    return res
  },
  getZY ({ state, commit }, receive = {}) {
    const data = [
      { id: '1', title: '律师' },
      { id: '2', title: '医师' },
      { id: '3', title: '心里咨询师' },
      { id: '4', title: '教师' },
      { id: '10', title: '其他' }
    ]
    setLocal('zy', data)
    return data
  },
  // 添加证书
  async setUsercertificateAdd ({ state, commit }, receive = {}) {
    const sendData = {
      ...userIdObj,
      ...receive
    }
    const res = await CallInterface(requestName.SET_USERCERTIFICATEADD, sendData, { interType: 'special', method: 'POST' })
    return res
  },
  // 修改证书
  async setUsercertificateEdit ({ state, commit }, receive = {}) {
    const sendData = {
      ...userIdObj,
      ...receive
    }
    const res = await CallInterface(requestName.SET_USERCERTIFICATEEDIT, sendData, { interType: 'special', method: 'PUT' })
    return res
  },
  // 删除证书
  async setUsercertificateDelete ({ state, commit }, receive = {}) {
    const sendData = {
      ...receive
    }
    const res = await CallInterface(requestName.SET_USERCERTIFICATEDELETE, sendData, { interType: 'special', method: 'DELETE' })
    return res
  }
}